import QtQuick 2.6
import QtQuick.Layouts 1.1
import Qt.labs.controls 1.0
import "../template" as Tm
import "../js/SecuritySettingNavigator.qml.js" as Jit
Tm.Navigator {
    id: nav
    title: "安全设置"

    Flickable {
        id: flickable

        Layout.fillHeight: true
        Layout.fillWidth: true
        contentWidth: parent.width
        contentHeight:720

        ScrollIndicator.vertical: ScrollIndicator { }
        ColumnLayout {
            anchors.fill: parent
            GroupBox {
                title:  "姓名修改"
                RowLayout {


                    Label {
                        text: "姓名"
                        Layout.alignment: Qt.AlignRight
                    }

                    TextField {
                        id: textName
                        Layout.preferredWidth: nav.width * 0.8
                        text: usinfo.name
                        readOnly: nameBtn.readonlyMode
                    }


                    ToolButton {
                         id: nameBtn
                        anchors.right: parent.right
                        anchors.rightMargin: 9
                        property bool readonlyMode: true
                        label:
                            Image {
                            anchors.centerIn: parent
                            source:  nameBtn.readonlyMode ?"../images/pencil.png"  : "../images/pencil-ok.png"
                        }

                        onClicked:  Jit.modifyName()
                    }
                }

            }

            GroupBox {
                title: "邮箱修改"
                RowLayout {


                    Label {
                        text: "邮箱"
                        Layout.alignment: Qt.AlignRight
                    }

                    TextField {
                        id: textMail
                        Layout.preferredWidth: nav.width * 0.8
                        readOnly: mailBtn.readonlyMode
                        text: usinfo.mail
                    }



                    ToolButton {
                        id: mailBtn
                        anchors.right: parent.right
                        anchors.rightMargin: 9
                        property bool readonlyMode: true
                        label:
                            Image {
                            anchors.centerIn: parent
                            source:  mailBtn.readonlyMode ?"../images/pencil.png"  : "../images/pencil-ok.png"
                        }

                        onClicked:  Jit.modifyMail()
                    }
                }

            }
            GroupBox{
                title: "密码修改"
                GridLayout {
                    anchors.centerIn: parent

                    columns: 2

                    Label {
                        text: "密码"
                        Layout.alignment: Qt.AlignRight
                    }

                    TextField {
                        id: passText
                        Layout.preferredWidth: nav.width * 0.8
                        echoMode: TextInput.Password
                    }

                    Label {
                        text: "再输一次"
                        Layout.alignment: Qt.AlignRight
                    }
                    TextField {
                        id: passwordTxt

                        Layout.preferredWidth: nav.width * 0.8

                        echoMode: TextInput.Password
                    }

                    Button {
                        Layout.columnSpan: 2
                        Layout.alignment: Qt.AlignHCenter
                        text: "确认"
                        onClicked: Jit.modify()
                    }
                }
            }
        }
    }
}
